package com.heima.schedule.client;

import com.heima.model.schedule.dtos.Task;
import com.heima.schedule.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/task")
public class ScheduleClient {

    @Autowired
    private TaskService taskService;

    /**
     * 拉取任务
     * @param type
     * @param priority
     * @return
     */
    @GetMapping("/poll/{type}/{priority}")
    public Task poll(@PathVariable int type, @PathVariable int priority){
        return taskService.poll(type,priority);
    }

    /**
     * 添加任务
     * @param task
     * @return
     */
    @PostMapping("/add")
    public long addTask(@RequestBody Task task){
        return taskService.addTask(task);
    }


}
